package game.players.user.movements;

import com.uqbar.vainilla.DeltaState;
import com.uqbar.vainilla.events.constants.Key;

import game.players.SoccerPlayer;

public class WithBallDiagonalRightUpMovingUser extends WithBallAbstractMovingUser {

	public WithBallDiagonalRightUpMovingUser(SoccerPlayer player, double x, double y) {
		super(player, x, y);
		this.getPlayer().setRightAnimationWithSpeed(0.1);
		this.getSoccerBall().setRightAnimationWithSpeed(0.01 * (0.05 + this.getPlayer().getMovementSpeed()));
		this.getSoccerBall().locateBall(this.getPlayer().getX() + this.getPlayer().getAppearance().getWidth()
                - this.getSoccerBall().getX() - this.getSoccerBall().getRatio(), 0);
	}
	
	@Override
	public void update(DeltaState deltaState) {
		if (!deltaState.isKeyBeingHold(Key.UP))
			this.getPlayer().setState(new WithBallRightMovingUser(this.getPlayer(), this.getX(), 0));
		
		if (!deltaState.isKeyBeingHold(Key.RIGHT))
			this.getPlayer().setState(new WithBallUpMovingUser(this.getPlayer(), 0, this.getY()));
		
		if (!deltaState.isKeyBeingHold(Key.RIGHT) && !deltaState.isKeyBeingHold(Key.UP))
			this.getPlayer().setState(new WithBallStationaryUser(this.getPlayer()));
		
		super.update(deltaState);
	}

	@Override
	public boolean isRight() {
		return true;
	}

}
